﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace sy1_5
{
    public partial class Form1 : Form
    {
        // 图片和图标绝对路径（请替换为你的实际文件路径）
        private string iconPath = @"E:\C#\sy1-5\music.ico";
        private string loadImgPath = @"E:\C#\sy1-5\Azul.jpg";
        private string clickImgPath = @"E:\C#\sy1-5\butterfly.jpg";
        private string doubleClickImgPath = @"E:\C#\sy1-5\17735ad4d869e4eaddb64a86a1ead737.jpg";

        public Form1()
        {
            InitializeComponent();
        }

        // 窗体载入事件
        private void Form1_Load(object sender, EventArgs e)
        {
            // 设置程序图标
            if (System.IO.File.Exists(iconPath))
                this.Icon = new Icon(iconPath);

            // 加载初始背景图
            if (System.IO.File.Exists(loadImgPath))
                this.BackgroundImage = Image.FromFile(loadImgPath);

            this.BackgroundImageLayout = ImageLayout.Stretch; // 图片拉伸适应窗体
            label1.Visible = false; // 隐藏标签
            label1.Text = "双击窗体显示的标签"; // 设置标签内容
        }

        // 窗体单击事件
        private void Form1_Click(object sender, EventArgs e)
        {
            // 切换为单击时的图片
            if (System.IO.File.Exists(clickImgPath))
                this.BackgroundImage = Image.FromFile(clickImgPath);

            label1.Visible = false; // 保持标签隐藏
        }

        // 窗体双击事件
        private void Form1_DoubleClick(object sender, EventArgs e)
        {
            // 切换为双击时的图片
            if (System.IO.File.Exists(doubleClickImgPath))
                this.BackgroundImage = Image.FromFile(doubleClickImgPath);

            label1.Visible = true; // 显示标签
        }
    }
}
